import request from '~/utils/resquest'

// 工单设置
export const getOrderSetList = <T>(params: T) => {
  return request({ url: '/api/gxsaas-produce/order/cfg/list', method: 'GET', params }) // 列表
}

export const postOrderSetAdd = <T>(data: T) => {
  return request({ url: '/api/gxsaas-produce/order/cfg/add', method: 'POST', data }) // 新增
}

export const getOrderSetView = <T>(params: T) => {
  return request({ url: '/api/gxsaas-produce/order/cfg/view', method: 'GET', params }) // 编辑 查看
}

export const postOrderSetUpdate = <T>(data: T) => {
  return request({ url: '/api/gxsaas-produce/order/cfg/update', method: 'POST', data }) // 编辑 更新
}

export const postOrderSetRemove = <T>(data: T) => {
  return request({ url: `/api/gxsaas-produce/order/cfg/remove?ids=${data}`, method: 'POST' }) // 删除
}

// 工单设置 运维部门
export const getDeptConfigList = <T>(params: T) => {
  return request({ url: '/api/gxsaas-produce/workArea/deptConfig/list', method: 'GET', params }) // 工单设置 运维部门管理 主列表
}

export const getDeptWorkareaList = <T>(params: T) => {
  return request({ url: '/api/gxsaas-assets/workarea/list', method: 'GET', params }) // 新增 选择对应工区 列表
}

export const postDeptConfigAdd = <T>(data: T) => {
  return request({ url: '/api/gxsaas-produce/workArea/deptConfig/add', method: 'POST', data }) // 新增->确定
}

export const getDeptConfigView = <T>(params: T) => {
  return request({ url: '/api/gxsaas-produce/workArea/deptConfig/view', method: 'GET', params }) // 编辑 查看
}

export const postDeptConfigUpdate = <T>(data: T) => {
  return request({ url: '/api/gxsaas-produce/workArea/deptConfig/update', method: 'POST', data }) // 编辑->确定
}

export const postDeptConfigRemove = <T>(data: T) => {
  return request({
    url: `/api/gxsaas-produce/workArea/deptConfig/remove?ids=${data}`,
    method: 'POST'
  }) // 删除
}

// 获取工单历史统计数据
export const getOrderCountInfo = () =>
  request({ url: '/api/gxsaas-produce/order/getOrderCountInfo', method: 'GET' })

// 查询工单列表
export const getOrderList = <T>(params: T) => {
  return request({ url: '/api/gxsaas-produce/order/list', method: 'GET', params })
}

// 工单详情
export const getOrderInfo = <T>(params: T) => {
  return request({ url: '/api/gxsaas-produce/order/view', method: 'GET', params })
}

// 新增工单 保存
export const postOrderAdd = <T>(data: T) => {
  return request({ url: '/api/gxsaas-produce/order/add', method: 'POST', data })
}

// 新增工单 保存并发送
export const postSaveAndSendOrder = <T>(data: T) => {
  return request({ url: '/api/gxsaas-produce/order/saveAndSendOrder', method: 'POST', data })
}

// 编辑工单
export const postOrderUpdate = <T>(data: T) => {
  return request({ url: '/api/gxsaas-produce/order/update', method: 'POST', data })
}

// 获取工单现存工单数据（地图标记点）
export const getExistOrderMapMarkerList = <T>(params: T) =>
  request({ url: '/api/gxsaas-produce/order/getExistOrderList', method: 'GET', params })

// 获取租户用户下拉列表
export const getTenantUserSelectList = () => {
  return request({ url: '/api/gxsaas-system/user/getTenantUserName', method: 'GET' })
}

// 获取设备所属部门下拉列表
export const getDeptTreeSelectList = () => {
  return request({ url: '/api/gxsaas-system/dept/getDeptTree', method: 'GET' })
}

// 确认（处理）工单时工单负责人下拉列表
export const getConfirmOrderHandleUserSelectList = <T>(params: T) =>
  request({
    url: '/api/gxsaas-produce/order/getOrderHandleUser',
    method: 'GET',
    params
  })

// 获取流程记录（工单管理） BusinessKey = orderId
export const getOrderManageProcessRecordListByBusinessKey = <T>(params: T) =>
  request({
    url: '/api/gxsaas-flowable/flowable/flowTask/commentsByBusinessKey',
    method: 'GET',
    params
  })

// 获取操作记录列表
export const getOperationRecordLisByOrderId = <T>(params: T) => {
  return request({
    url: '/api/gxsaas-system/operationLog/listByBusinessKey',
    method: 'GET',
    params
  })
}

// 工单发送
export const postOrderSend = <T>(params: T) =>
  request({ url: '/api/gxsaas-produce/order/sendOrder', method: 'POST', params })

// 工单删除
export const postOrderRemove = <T>(params: T) =>
  request({ url: '/api/gxsaas-produce/order/remove', method: 'POST', params })

// 确认工单
export const postOrderConfirm = <T>(data: T) =>
  request({ url: '/api/gxsaas-produce/order/confirmOrder', method: 'POST', data })

// 回退工单
export const postOrderBack = <T>(params: T) =>
  request({ url: '/api/gxsaas-produce/order/backOrder', method: 'POST', params })

// 终结工单
export const postOrderEnd = <T>(data: T) =>
  request({ url: '/api/gxsaas-produce/order/endOrder', method: 'POST', data })

// 归档工单
export const postOrderRegular = <T>(data: T) =>
  request({ url: '/api/gxsaas-produce/order/regularOrder', method: 'POST', data })
